# 求1+2!+3!+...+20!的和

# 方法1
total = 0
for i in range(1,21):
    r = 1
    for j in range(1, i + 1):
        r *= j
    total += r
print (total)

# 方法2
n = 0
s = 0
t = 1
for n in range(1,21):
    t *= n
    s += t
print ('1! + 2! + 3! + ... + 20! = %d' % s)